<?php
namespace app\admin\model;

use think\Model;
use think\Db;


class Article extends Model
{
    protected $pk = 'a_id';
    protected $autoWriteTimestamp = true;
    protected $table = 'xc_article';
    
    
    //获取器： 
	public function getCatetitleAttr($value,$data){
        $titles = Db::name('Cate')->where('id','in',$data['cate_id'])->column('title');
        return implode(',', $titles);
	}
    
    //搜索器
    public function searchTitleAttr($query, $value){
        
       if ($value) {
            $query->where('title', 'like', '%' . $value . '%');
        } 
        
    }
    public function searchFilesAttr($query, $value){
        
       if ($value) {
            $query->where('files', 'like', '%' . $value . '%');
        } 
        
    }
    
}


?>